package retrofix;

import retrofix.api.BiliService;
import retrofix.api.constants.ApiConstants;
import retrofix.entity.BiliDingVideo;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017-03-14.
 */
public class BaseRetrofit {


    public static void main(String arg[]) {


        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(ApiConstants.BILI_BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .client(httpClient.build())
                .build();

        BiliService service = retrofit.create(BiliService.class);
        Call<BiliDingVideo> call = service.getDingVideos();

        call.enqueue(new Callback<BiliDingVideo>() {

            public void onResponse(Call<BiliDingVideo> call, Response<BiliDingVideo> response) {
                // The network call was a success and we got a response
                // TODO: use the repository list and display it
                System.out.println(response.body());
            }

            public void onFailure(Call<BiliDingVideo> call, Throwable t) {
                // the network call was a failure
                // TODO: handle error

            }
        });

    }

}
